#ifndef FACEPROCESSOR_H
#define FACEPROCESSOR_H

#include "face_detector/include/face_detector.h"
#include "face_recognizer/include/face_recognizer.h"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <float.h>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <utility>
#include <QString>


class FaceProcessor
{
public:


    FaceProcessor();
    ~FaceProcessor();

    void regis();
    void identify(cv::Mat &frame,cv::Rect &face_roi,std::string &result,int &flag);


    void face_register(easyface::FaceDetector *detector, easyface::FaceRecognizer *recognizer,
        const std::string &register_imagepath, std::map<std::string, std::vector<float>> &username_feature_map);

    void face_identify(easyface::FaceDetector *detector,
                       easyface::FaceRecognizer *recognizer,
                       const std::map<std::string,std::vector<float>> &username_feature_map,
                        cv::Mat &img,cv::Rect &face_roi,std::string &result,int &flag);

    void setRegisterImagepath(QString path);
private:
    std::string detector_modelpath;
    std::string recognizer_modelpath ;
    std::string register_imagepath ;
    std::string identify_filename ;
    std::map<std::string, std::vector<float>> username_feature_map;
    std::map<std::string,int> username_num_map;

    easyface::FaceDetector *detector;
    easyface::FaceRecognizer *recognizer;

    bool prepro_detect_result(const FaceObject &obj,cv::Mat &img,int &flag);
    double get_front_pose_ratio(const std::vector<cv::Point2f> &landmark );
    double get_dist(cv::Point2f p1,cv::Point2f p2);
    std::string get_max_similarity(std::vector<float> &feature,const std::map<std::string,std::vector<float>> &username_feature_map);



};

#endif // FACEPROCESSOR_H
